using Godot;
using System;

public partial class InputTest2 : Node
{
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		if (Input.IsActionJustPressed("左"))
		{
			// 获取当前场景
			Node root = this.GetTree().CurrentScene;
			// 获取子节点
			Node test = root.FindChild("Test");
			// 删除节点
			// test.QueueFree();
			// 移除节点
			root.RemoveChild(test);
			// 添加节点
			this.AddChild(test);
		}

		if (Input.IsActionJustPressed("右"))
		{
			// 获取当前场景
			Node root = this.GetTree().CurrentScene;
			// 新建子节点
			Node2D node2D = new Node2D();
			// 设置名字
			node2D.Name = "New";
			// 添加节点
			root.AddChild(node2D);
		}
	}
}
